package com.angel.kuaidi.activity;

import com.angel.kuaidi.R;
import com.angel.kuaidi.utils.UtilsLog;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MoreActivity extends BaseActivity {

	private static final String url = "";

	private static final int HAVE = 0;
	private static final int NONE = 1;

	TextView tv_email;
	TextView tv_score;

	Button btn_add;
	Button btn_get;// 获取积分

	String email;

	int currentType = HAVE;

	private float density = 1.0f;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setView(R.layout.more);
		setTitle("返回", "更多", "分享软件");

		initData();
		initView();
		registerListener();
		display();
		adView();

	}
	private void adView() {

		View v = findViewById(R.id.adview);
		SharedPreferences share = mContext.getSharedPreferences("adview_flag", Context.MODE_PRIVATE);
		if (share.getBoolean("flag", false)) {
			v.setVisibility(View.VISIBLE);
		} else {
			v.setVisibility(View.GONE);
		}
	}

	@Override
	protected void onRightBtnClick() {
		super.onRightBtnClick();
		//
		Intent intent = new Intent(Intent.ACTION_SEND);
		intent.setType("image/*");
		intent.putExtra(Intent.EXTRA_SUBJECT, "分享");
		intent.putExtra(Intent.EXTRA_TEXT, "#软件分享#我正在使用#快递查查#来查询快递，支持上百家快递公司查询，相当好用，你也来下载一个吧！下载链接:" + url);

		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		startActivity(Intent.createChooser(intent, getTitle()));
	}

	private void initData() {
		email = mApp.getShareManager().getEmailAddress(mContext);
		density = getResources().getDisplayMetrics().density;
	}

	private void initView() {

		tv_score = (TextView) findViewById(R.id.tv_score);

		btn_get = (Button) findViewById(R.id.btn_get);

		// 广告
		// LinearLayout adViewLayout = (LinearLayout)
		// findViewById(R.id.adViewLayout);
		// adViewLayout.addView(new AdView(this), new
		// LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
		// LinearLayout.LayoutParams.WRAP_CONTENT));

	}

	private void registerListener() {

		btn_get.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// YoumiOffersManager.showOffers(MoreActivity.this,
				// YoumiOffersManager.TYPE_REWARD_OFFERS);
			}
		});

	}

	private void display() {

		// Utils.showProcessDialog(mContext);

	}

	@Override
	protected void onResume() {
		super.onResume();
		showPoint();
	}

	private void showPoint() {
		UtilsLog.i("msg", "resume");
		// tv_score.setText(Integer.toString(YoumiPointsManager.queryPoints(this))
		// + "分");
	}
}
